//
//  XLMenuViewCell.m
//  PopMenu_QQ_Demo
//
//  Created by yuanxiaolong on 16/3/28.
//  Copyright © 2016年 yuanxiaolong. All rights reserved.
//

#import "XLMenuViewCell.h"

@interface XLMenuViewCell ()


@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *iconView;


@end

@implementation XLMenuViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews {
    _titleLabel = [UILabel new];
    _titleLabel.font = [UIFont systemFontOfSize:14];
    _titleLabel.textColor = KHEXCOLOR(AllBackColor_titleColor);
    
    _iconView = [UIImageView new];
    _iconView.contentMode = UIViewContentModeCenter;
    _iconView.backgroundColor = [UIColor clearColor];
    
    _lineV=[[UIView alloc]init];
    _lineV.backgroundColor=KHEXCOLOR(IM_Color_SeparateLine);
    _lineV.frame=CGRectMake(20, 46, self.contentView.width-40, 0.5);
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.lineV];

    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(20);
        make.width.height.equalTo(@30);
        make.centerY.equalTo(self.contentView);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconView.mas_right).offset(10);
        make.height.equalTo(@20);
        make.width.lessThanOrEqualTo(@100);
        make.centerY.equalTo(self.contentView);
    }];
//    [self.lineV mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.left.equalTo(self.contentView).offset(20);
//        make.bottom.equalTo(self.contentView).offset(-0.5);
//        make.right.equalTo(self.contentView).offset(-20);
//    }];
}

- (void)setTitle:(NSString *)title {
    _title = title;
    _titleLabel.text = title;
}

- (void)setImageName:(NSString *)imageName {
    _imageName = imageName;
    self.iconView.image = [UIImage imageNamed:imageName];
}


@end
